//
//  HomeModel.m
//  SleepingElf
//
//  Created by karong on 2023/10/9.
//

#import "HomeModel.h"

@implementation HomeModel
- (NSInteger)rowWithSection:(NSInteger)section {
    NSInteger row = 0;
    switch (section) {
        case 0:
            row = 1;
            break;
        case 1:
            row = self.tabArray.count;
            break;
        case 2:
            row = 1;
            break;
        case 3:
            row = 1;
            break;
        case 4:
            row = self.classifyListArray.count;
            break;
        case 5:
            row = 1;
            break;
        case 6:
            row = self.exclusiveArray.count;
            break;
        default:
            break;
    }
    return row;
}

- (CGSize)sizeWithSection:(NSInteger)section {
    CGSize size = CGSizeZero;
    CGFloat width = SEScreenWidth;
    switch (section) {
        case 0:
            size.width = width;
            size.height = floor((width - 13 - 13) * 222 / 364.0f);
            break;
        case 1:
        {
            UIImage * bg = SEIMG(@"bg_tab_1");
            size = bg.size;
        }
            break;
        case 2:
            size.width = width;
            size.height = floor((width - 13 - 20 - 20) / 2.7) + 29;
            break;
        case 3:
            size.width = width;
            size.height = 22;
            break;
        case 4:
            size.width = width;
            size.height = 55;
            break;
        case 5:
            size.width = width;
            size.height = floor((width - 13 - 20 - 20) / 2.7) + 24;
            break;
        case 6:
            size.width = floor((width - 13 - 13 - 32) / 2.0f);
            size.height = size.width;
            break;
        default:
            break;
    }
    return size;
}

- (NSString *)cellClassWithSection:(NSInteger)section {
    NSString * cellClass = @"";
    switch (section) {
        case 0:
            cellClass = @"HomeBannerCell";
            break;
        case 1:
            cellClass = @"HomeTabCell";
            break;
        case 2:
            cellClass = @"HomeFeaturedCell";
            break;
        case 3:
            cellClass = @"HomeClassifyCell";
            break;
        case 4:
            cellClass = @"HomeClassifyMusicCell";
            break;
        case 5:
            cellClass = @"HomeLullabyCell";
            break;
        case 6:
            cellClass = @"HomeMusicCell";
            break;
        default:
            break;
    }
    return cellClass;
}

- (UIEdgeInsets)insetWithSection:(NSInteger)section {
    UIEdgeInsets inset = UIEdgeInsetsZero;
    
    switch (section) {
        case 0:
            inset.bottom = 36;
            break;
        case 1:
            inset.left = 13;
            inset.right = 13;
            inset.bottom = 6;
            break;
        case 2:
            inset.bottom = 18;
            break;
        case 3:
            inset.bottom = 18;
            break;
        case 4:

            break;
        case 5:
            inset.bottom = 10;
            break;
        case 6:
            inset.left = 13;
            inset.right = 13;
            inset.bottom = 20;
            break;
        default:
            break;
    }
    return inset;
}

- (NSString *)headTitleWithSection:(NSInteger)section {
    NSString * title = @"";
    switch (section) {
        case 2:
            title = WSLocalized(@"精选白噪音");
            break;
        case 5:
            title = WSLocalized(@"催眠曲");
            break;
        case 6:
            title = WSLocalized(@"助眠放松");
            break;
        default:
            break;
    }
    return title;
}

- (CGSize)headSizeWithSection:(NSInteger)section {
    CGSize size = CGSizeZero;
    CGFloat width = SEScreenWidth;
    switch (section) {
        case 2:
        case 5:
        case 6:
            size.width = width;
            size.height = 46;
            break;
        default:
            break;
    }
    return size;
}

- (id)didSelectWithIndexPath:(NSIndexPath *)indexPath {
        id object;
        switch (indexPath.section) {
            case 1:
                object = self.tabArray[indexPath.row];
                break;
            case 4:
                object = self.classifyListArray[indexPath.row];
                break;
            case 6:
                object = self.exclusiveArray[indexPath.row];
                break;
            default:
                break;
        }
        return object;
}

- (NSInteger)category_idWithSection:(NSInteger)section {
    NSInteger category_id = -1;
    MusicModel * music;
    switch (section) {
        case 2:
            if (self.featuredArray.count > 0) {
                music = self.featuredArray.firstObject;
            }
            break;
        case 4:
            if (self.classifyListArray.count > 0) {
                music = self.classifyListArray.firstObject;
            }
            break;
        case 5:
            if (self.lullabyArray.count > 0) {
                music = self.lullabyArray.firstObject;
            }
            break;
        case 6:
            if (self.exclusiveArray.count > 0) {
                music = self.exclusiveArray.firstObject;
            }
            break;
        default:
            break;
    }
    if (music) {
        category_id = music.category_id;
    }
    return category_id;
}
@end
@implementation HomeBanner

@end
@implementation HomeTab

@end
@implementation HomeClassify
+ (NSDictionary *)mj_replacedKeyFromPropertyName {
    return @{@"describe":@"description"};
}

+ (NSDictionary *)mj_objectClassInArray {
    return @{@"children":NSClassFromString(@"HomeClassify")};
}

@end
